;
(function(window, undefined) {
    function init(el) {
        //获取所有数据
        let els = document.querySelectorAll(el)
            //遍历数据，将js dom 绑定到jq对象上
        for (let i = 0; i < el.length; i++) {
            //获取js标签对象
            this[i] = els[i]
        }
        this.length = els.length
    }
    let jQuery = function(el) { //element
            return new init(el)
        }
        //jQuery.extend() 函数用于将一个或多个对象的内容合并到目标对象
    jQuery.extend = function(object) {
            for (let key in object) {
                init.prototype[key] = object[key]
            }
        }
        //原型方法
    init.prototype = {
        //添加样式
        css(cssAttr, cssValue) {
            for (let i = 0; i < this.length; i++) {
                this[i].style[cssAttr] = cssValue;
            }
            return this
        },
        //添加属性
        attr(attrClass, attrValue) {
            for (let i = 0; i < this.length; i++) {
                this[i].setAttribute([attrClass], attrValue)
            }
            return this
        },
        //移除属性
        removeAttr(attrClass) {
            for (let i = 0; i < this.length; i++) {
                this[i].removeAttribute(attrClass)
            }
        },
        //添加class
        addClass(className) {
            for (let i = 0; i < this.length; i++) {
                this[i].classList.add(className);
            }
        },
        //移除class
        removeClass(className) {
            for (let i = 0; i < this.length; i++) {
                this[i].classList.remove(className);
            }
        }
    }
    window.jQuery = window.$ = jQuery
})(window)